package cn.kgc.controller;

import cn.kgc.pojo.Detail;
import cn.kgc.service.DetailService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("yuzepeng")
public class DetailController {

    @Resource
    DetailService detailService;

    @RequestMapping("select")
    public String select(@RequestParam(value = "projectId",required = false,defaultValue = "") Integer projectId, Model model){
        List<Detail> select = detailService.select(projectId);
        model.addAttribute("select",select);
        return  "index";
    }


    @RequestMapping("add")
    public String add(Detail detail){
        detail.setCreateDate(new Date());
              detailService.add(detail);

              return  "redirect:/yuzepeng/select";
    }

}
